package com.maxatime.service.impl;

import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.maxatime.dao.tStudentMapper;
import com.maxatime.pojo.entity.tStudent;
import com.maxatime.pojo.entity.tStudent2;
import com.maxatime.service.Homeser;
import com.maxatime.util.SerialNumberUtil;

@Service
public class HomeImpl implements Homeser{
	@Autowired
	tStudentMapper tStudentMapper;
	
	@Override
	public int deleteByPrimaryKey(Integer studentNo) {
		// TODO Auto-generated method stub
		return tStudentMapper.deleteByPrimaryKey(studentNo);
	}

	@Override
	public int insert(tStudent record) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public int insertSelective(tStudent2 record) {
		// TODO Auto-generated method stub
		tStudent2 tstudent2 = new tStudent2();
		BeanUtils.copyProperties(record, tstudent2);
		String StuPass = String.valueOf(SerialNumberUtil.getRandomNum());
		tstudent2.setStuPass(StuPass);
		tStudentMapper.insertSelective(tstudent2);
		return 0;
	}

	@Override
	public tStudent selectByPrimaryKey(Integer studentNo) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public int updateByPrimaryKeySelective(tStudent2 record) {
		// TODO Auto-generated method stub
		return tStudentMapper.updateByPrimaryKeySelective(record);
	}

	@Override
	public int updateByPrimaryKey(tStudent record) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public Map<String, Object> list(tStudent2 tStudent2) {
		// TODO Auto-generated method stub
		PageHelper.startPage(tStudent2.getPageNum(), tStudent2.getPageSize());
		List<tStudent2> listDemo = tStudentMapper.list(tStudent2);
		PageInfo<tStudent2> pageInfo = new PageInfo<tStudent2>(listDemo);
		Map<String, Object> m = new HashMap<String, Object>();
		m.put("list", listDemo);
		m.put("pageInfo", pageInfo);
		return m;
	}

	@Override
	public tStudent2 find(int studentNo) {
		// TODO Auto-generated method stub
		return tStudentMapper.find(studentNo);
	}

	@Override
	public tStudent2 ckstudentNo(int studentNo) {
		// TODO Auto-generated method stub
		return tStudentMapper.ckstudentNo(studentNo);
	}

	

}
